/**
 *
 * @(#) FileTest.java
 * @Package io
 * 
 * Copyright © *** Corporation. All rights reserved.
 *
 */

package com.chen.io;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 *  类描述：
 * 
 *  @author:  Administrator
 *  @version  $Id: Exp$ 
 *           
 */
public class FileTest {

	public static void main(String[] args) {
		String filepath = "D:/filetest/creat1.txt";
		//creatFile(filepath);
		getAllFile("D:/filetest",0);
	}
	
	public static void getAllFile(String filepath,int i){
		File file = new File(filepath);
		StringBuffer nbsp=new StringBuffer();
		for(int j=0;j<i;j++){
			nbsp.append("—— ");
		}
		if(file.exists()){
			File[] files = file.listFiles();
			for(File temp:files){
				if(temp.isDirectory()){
					System.out.println(nbsp.toString()+temp.getName());
					getAllFile(temp.getAbsolutePath(),i+1);
				}else{
					System.out.println(nbsp.toString()+temp.getName());
				}
			}
		}
	}

	public static void creatFile(String filepath){
		String encoding = "UTF-8";
		try {
			FileOutputStream fos = new FileOutputStream(filepath);
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
